package com.fjnldx.ks.service;

import com.fjnldx.ks.mapper.MesScjhMapper;
import com.fjnldx.ks.pojo.mesDoMain.*;
import com.fjnldx.ks.pojo.request.Gx;
import com.fjnldx.ks.pojo.request.ScjhReq2;
import com.fjnldx.ks.pojo.request.ScjhReq3;
import com.fjnldx.ks.pojo.response.Result;
import com.fjnldx.ks.utils.Common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class MesScjhService {
    @Autowired
    MesScjhMapper mesScjhMapper;
    @Autowired
    Common common;

    /**
     * 查询各工序理论总产量
     */
    public Result getMesScjhByTime() {
        List<ScjhZc> mesScjhByTime = mesScjhMapper.getMesScjhByTime();
        return Result.success(mesScjhByTime);
    }
    /**
     * 查询各工序品种理论总产量
     */
    public Result getMesScjhLlPzZc(Gx gx) {
        String gongxu = gx.getGongxu();
        List<PzZc> res = mesScjhMapper.getMesScjhLlPzZc(gongxu);
        return Result.success(res);
    }
    /**
     * 查询各工序品种实际总产量
     */
    public Result getMesScjhSjPzZc(Gx gx) {
        List<PzSjZc> res = new ArrayList<>();
        switch (gx.getGongxu()) {
            case "细纱": // 细纱
                res = mesScjhMapper.getMesScjhSjPzZcXisha();
                break;
            case "粗纱": // 粗纱

                break;
            default:
                break;
        }
        return Result.success(res);
    }

    /**
     * 查询各工序各设备的理论台产
     */
    public Result getMesScjhTcByDevSn(ScjhReq2 scjhReq2) {
        List<ScjhTc> res = mesScjhMapper.getMesScjhTcByDevSn(scjhReq2);
        return Result.success(res);
    }

    /**
     * 查询各工序实际总产量
     */
    public Result getMesScjhSjZc() {
        List<ScjhSjZc> res = mesScjhMapper.getMesScjhSjZcXiSha();
        return Result.success(res);
    }

    /**
     * 根据设备号查询各工序台产
     */
    public Result getMesScjhSjTc(ScjhReq3 scjhReq3) {
        List<ScjhTc> res = new ArrayList<>();
        switch (scjhReq3.getGongxu()) {
            case "细纱": // 细纱
                res = mesScjhMapper.getMesScjhSjTcXiSha(scjhReq3);
                break;
            case "粗纱": // 粗纱

                break;
            default:
                break;
        }
        return Result.success(res);
    }
}
